import { mapGetters } from 'vuex'
export default {
  data() {
    return {
      tabsActivity: 'commission',
      paneData: {},
      editing: false
    }
  },
  computed: {
    ...mapGetters(['customerId'])
  },
  mounted() {
    this.$$cache = {}
    this.getCommission()
  },
  methods: {
    async getCommission() {
      const { success, data } = await this.$api.getCommission({ merchantId: this.customerId })
      if (success) {
        this.paneData = data
        this.$$cache = { ...data }
      }
    },
    doCancel() {
      // console.log(this.$$cache, 'sss')
      this.paneData = { ...this.$$cache }
      this.editing = false
    },
    async doSave() {
      // -
      const params = {
        ratio1: this.paneData.ratio1,
        ratio2: this.paneData.ratio2,
        merchantId: this.customerId
      }
      const { success } = await this.$api.saveCommission(params)
      if (success) {
        this.editing = false
        this.$message.success('设置成功')
      }
    }
  }
}
